<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns:MSHelp="http://www.microsoft.com/MSHelp/" lang="en-us" xml:lang="en-us"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta name="DC.Type" content="reference">
<meta name="DC.Title" content="aggregator Class Basic Interface">
<meta name="DC.subject" content="aggregator Class Basic Interface">
<meta name="keywords" content="aggregator Class Basic Interface">
<meta name="DC.Relation" scheme="URI" content="../../../../reference/appendices/community_preview_features/aggregator_cls.htm">
<meta name="DC.Relation" scheme="URI" content="expert_interface.htm">
<meta name="DC.Format" content="XHTML">
<meta name="DC.Identifier" content="basic_interface">
<meta name="DC.Language" content="en-US">
<link rel="stylesheet" type="text/css" href="../../../../intel_css_styles.css">
<title>aggregator Class Basic Interface</title>
<xml>
<MSHelp:Attr Name="DocSet" Value="Intel"></MSHelp:Attr>
<MSHelp:Attr Name="Locale" Value="kbEnglish"></MSHelp:Attr>
<MSHelp:Attr Name="TopicType" Value="kbReference"></MSHelp:Attr>
</xml>
</head>
<body id="basic_interface">
 <!-- ==============(Start:NavScript)================= -->
 <script src="..\..\..\..\NavScript.js" language="JavaScript1.2" type="text/javascript"></script>
 <script language="JavaScript1.2" type="text/javascript">WriteNavLink(4);</script>
 <!-- ==============(End:NavScript)================= -->
<a name="basic_interface"><!-- --></a>

 
  <h1 class="topictitle1">aggregator Class Basic Interface</h1>
 
   
  <div> 
	 <div class="section"><h2 class="sectiontitle">Syntax</h2> 
		 
		<pre>class aggregator;</pre> 
	 </div>
 
	 <div class="section"><h2 class="sectiontitle">Header</h2> 
		 
		<pre>#define TBB_PREVIEW_AGGREGATOR 1
#include "tbb/aggregator.h"</pre> 
	 </div>
 
	 <div class="section"><h2 class="sectiontitle">Description</h2> 
		 
		<p>An <samp class="codeph">aggregator</samp> is similar to a <samp class="codeph">mutex</samp> in that it allows for mutually 
           exclusive execution of operations, however the interface is quite different.  In particular, operations 
           (in the form of function bodies or lambda functions) are passed to an <samp class="codeph">aggregator</samp> for 
           execution via an <samp class="codeph">execute</samp> method on the <samp class="codeph">aggregator</samp> object.  Operations 
           passed to the same <samp class="codeph">aggregator</samp> object will be executed mutually exclusively.  
           The <samp class="codeph">execute</samp> method returns after the function passed to it has completed execution.
		</p>
 
	 </div>
 
	 <div class="section"><h2 class="sectiontitle">Members</h2> 
		 
		<pre>namespace tbb {
  class aggregator {
  public:
    aggregator();
    template&lt;typename Body&gt; 
    void execute(const Body&amp; b);
  };
}</pre> 
		
<div class="tablenoborder"><table cellpadding="4" summary="" frame="border" border="1" cellspacing="0" rules="all"><span class="tabledesc">The following table provides additional information on the
			 members of this class. 
		  </span>
             <thead align="left"> 
				<tr> 
				  <th class="cellrowborder" valign="top" width="33.89830508474576%" id="d17477e97">Member 
				  </th>
 
				  <th class="cellrowborder" valign="top" width="66.10169491525423%" id="d17477e100">Description 
				  </th>
 
				</tr>

             </thead>
 
			 <tbody> 
				<tr> 
				  <td class="cellrowborder" valign="top" width="33.89830508474576%" headers="d17477e97 "><span class="keyword">aggregator()</span> 
				  </td>
 
				  <td class="cellrowborder" valign="top" width="66.10169491525423%" headers="d17477e100 "> 
					 <p>Constructs an <span class="keyword">aggregator</span> object.
					 </p>
 
				  </td>
 
				</tr>
 
				<tr> 
				  <td class="cellrowborder" valign="top" width="33.89830508474576%" headers="d17477e97 "><span class="keyword">template&lt;typename Body&gt; void execute(const Body&amp; b)</span> 
				  </td>
 
				  <td class="cellrowborder" valign="top" width="66.10169491525423%" headers="d17477e100 "> 
					 <p>Submits <samp class="codeph">b</samp> to <span class="keyword">aggregator</span> to be executed in a mutually 
                     exclusive fashion.  Returns after <samp class="codeph">b</samp> has been executed.</p>
 
				  </td>
 
				</tr>
 
			 </tbody>
 
		  </table>
</div>
 
  </div>
 
  <div class="section"><h2 class="sectiontitle">Example</h2> 
   
  <p>The following example uses an <samp class="codeph">aggregator</samp> to safely operate on a non-concurrent <samp class="codeph">std::priority_queue</samp> container.</p>

 <pre>typedef priority_queue&lt;value_type, vector&lt;value_type&gt;, compare_type&gt; pq_t;
pq_t my_pq;
aggregator my_aggregator;
value_type elem = 42;

// push elem onto the priority queue
my_aggregator.execute( [&amp;my_pq, &amp;elem](){ my_pq.push(elem); } );

// pop an elem from the priority queue
bool result = false;
my_aggregator.execute( [&amp;my_pq, &amp;elem, &amp;result](){
  if (!my_pq.empty()) {
    result = true;
    elem = my_pq.top();
    my_pq.pop();
  }
} );</pre>
  </div>
 
  </div>
 
  
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong>&nbsp;<a href="../../../../reference/appendices/community_preview_features/aggregator_cls.htm">aggregator Class</a></div>
</div>
<div class="See Also">
<h2>See Also</h2>
<div class="linklist">
<div><a href="expert_interface.htm">aggregator Class Expert Interface
		  </a></div></div>
</div>

</body>
</html>
